package cn.xopencode.recordservice.provider.kvtransformer;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.manager.kvtransformer.KvTransformerRecordManager;
import cn.xopencode.recordservice.rpc.kvtransformer.KvTransformerRecordRpc;
import cn.xopencode.recordservice.rpc.kvtransformer.dto.KvTransformerRecordCreateDTO;
import cn.xopencode.recordservice.rpc.kvtransformer.dto.KvTransformerRecordPageDTO;
import cn.xopencode.recordservice.rpc.kvtransformer.dto.KvTransformerRecordUpdateDTO;
import cn.xopencode.recordservice.rpc.kvtransformer.vo.KvTransformerRecordAdminPageVO;
import cn.xopencode.recordservice.rpc.kvtransformer.vo.KvTransformerRecordPageVO;
import cn.xopencode.recordservice.rpc.kvtransformer.vo.KvTransformerRecordUpdateVO;
import cn.xopencode.recordservice.rpc.robotroom.dto.AdminRecordPageDTO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 10KV变压器巡检记录 Rpc 实现类
 */
@DubboService(version = "${dubbo.provider.KvTransformerRecordRpc.version}")
public class KvTransformerRecordRpcImpl implements KvTransformerRecordRpc {

    @Autowired
    private KvTransformerRecordManager kvTransformerRecordManager;

    @Override
    public CommonResult<Integer> createKvTransformerRecord(KvTransformerRecordCreateDTO createDTO) {
        Integer result = kvTransformerRecordManager.createKvTransformerRecord(createDTO);
        return CommonResult.success(result);
    }

    @Override
    public CommonResult<PageResult<KvTransformerRecordPageVO>> pageKvTransformerRecord(KvTransformerRecordPageDTO pageDTO) {
        return CommonResult.success(kvTransformerRecordManager.pageKvTransformerRecord(pageDTO));
    }

    @Override
    public CommonResult<KvTransformerRecordUpdateVO> getKvTransformerRecordById(String id) {
        return CommonResult.success(kvTransformerRecordManager.getKvTransformerRecordById(id));
    }

    /**
     * 更新KV变压器
     *
     * @param updateDTO
     * @return
     */
    @Override
    public CommonResult<Integer> updateKvTransformerRecord(KvTransformerRecordUpdateDTO updateDTO) {
        Integer result = kvTransformerRecordManager.updateKvTransformerRecord(updateDTO);
        return CommonResult.success(result);
    }

    @Override
    public CommonResult<Integer> dealKvTransformerRecordException(String recordId) {
        return CommonResult.success(kvTransformerRecordManager.dealKvTransformerRecordException(recordId));
    }

    @Override
    public CommonResult<PageResult<KvTransformerRecordAdminPageVO>> getAdminPageKvTransformerRecord(AdminRecordPageDTO pageDTO) {
        return CommonResult.success(kvTransformerRecordManager.getAdminPageKvTransformerRecord(pageDTO));
    }
}
